﻿@model Data.Web.News 
@{  
    var Media = System.Configuration.ConfigurationManager.AppSettings["Media"];
    var Upload = System.Configuration.ConfigurationManager.AppSettings["Upload"];
   
}
@section head {

  <script src="/Libs/ckeditor/ckeditor.js"></script>   
	<script type="text/javascript">
	    $(document).ready(function () {
	        CKEDITOR.replace('Content', {
	            language: 'vi'

	        });
	            $("form").submit(function () {
	                var selTypeText = $("#UserId option:selected").text();
	                selTypeText = selTypeText.replace(/_/gi, '');
	                $("#UserName").val($.trim(selTypeText));  

	                var selTypeText = $("#CateId option:selected").text();
	                selTypeText = selTypeText.replace(/_/gi, '');
	                $("#CateName").val($.trim(selTypeText)); 
	            });
		    });
	</script>

}  
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>News</legend>
        @Html.HiddenFor(model => model.DateCreate) 
        @Html.HiddenFor(model => model.Id)
          @Html.HiddenFor(model => model.CateName)
        @Html.HiddenFor(model => model.UserName)
        @Html.HiddenFor(model => model.UserId)
        <div class="editor-label">
            Danh mục 
        </div>
        <div class="editor-field">
            @Html.DropDownList("CateId") 
        </div>

        <div class="editor-label">
           Tiêu đề 
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div> 
        <div class="editor-label">
           Mô tả 
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div> 
        <div class="editor-label">
           Nội dung 
        </div>
        <div class="editor-field" style="width:700px">
            @Html.TextAreaFor(model => model.Content)
            @Html.ValidationMessageFor(model => model.Content)
        </div>

        <div class="editor-label">
           Hình ảnh 
        </div>
        <div class="editor-field">
              @if (!string.IsNullOrEmpty(Model.Image))
              { 
                <img src="@Html.Raw(Media + "Thumbnail/" + Model.Image)" style="max-height:50px;" />          
              } 
          @Html.EditorFor(model => model.Image)
            <a href="@Upload" target="_parent"  onclick="window.open('@Upload', 'newwindow',  [ 'width=1024,height=700',
                            'width=1024,height=900,scrollbars=yes' ]); return false;">Tải ảnh</a>
        </div>

        <div class="editor-label">
            Hiển thị
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Satus)
            @Html.ValidationMessageFor(model => model.Satus)
        </div>
        <div class="editor-label">
          Thứ tự
        </div>
        <div class="editor-field">            
            <input type="number" name="Orderby" value="@Model.Orderby" id="Orderby" /> 
        </div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Quay lại trang danh sách", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
